package com.example.test;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * TODO: 这里要写注释的!
 */
public class UserValidaterMain {
    public static void main(String[] args) {
        String userName="test";
        String password= "test";
        UserValidator userValidator1= new UserValidator("LDAP");
        UserValidator userValidator2= new UserValidator("DataBase");
        TaskValidator ldap= new TaskValidator(userValidator1,userName,password);
        TaskValidator db= new TaskValidator(userValidator2,userName,password);
        List<TaskValidator> taskValidators= new ArrayList<>();
        taskValidators.add(ldap);
        taskValidators.add(db);
        ExecutorService executorService= Executors.newCachedThreadPool();
        String result=null;
        try {
            result= executorService.invokeAny(taskValidators);
            System.out.printf("main: result: %s\n", result);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
        executorService.shutdown();
        System.out.print("main: end of the execution\n");
    }
}
